package com.lcn.comm.domain;

/**
 * <p>类说明</p>
 *
 * @author 张峰 zfvip_it@163.com
 * @create: 上午9:29
 */
public class TxTransactionLocal {

    private final static ThreadLocal<TxTransactionLocal> currentLocal = new ThreadLocal<TxTransactionLocal>();

    /**
     * 事务组id
     */
    private String groupId;

    /**
     * 请求id
     */
    private String requestId;

    /**
     * 最大超时时间
     */
    private int requestTimeout;

    /**
     * 是否已创建连接对象
     */
    private boolean hasConnection;

    /**
     * 是否是发起方模块
     */
    private boolean hasStart = false;

    /**
     * 是否同一模块节点
     */
    private boolean hasGroup = false;

    /**
     * 是否只读事务
     */
    private boolean readOnly = false;

    /**
     * 是否唯一节点
     */
    private boolean hasOnlyNode = true;

    /**
     * ip+端口
     */
    private String ipPort;


    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public static void setCurrent(TxTransactionLocal current) {
        currentLocal.set(current);
    }

    public static TxTransactionLocal current() {
        return currentLocal.get();
    }

    public int getRequestTimeout() {
        return requestTimeout;
    }

    public void setRequestTimeout(int requestTimeout) {
        this.requestTimeout = requestTimeout;
    }

    public boolean isHasConnection() {
        return hasConnection;
    }

    public void setHasConnection(boolean hasConnection) {
        this.hasConnection = hasConnection;
    }

    public boolean isHasStart() {
        return hasStart;
    }

    public void setHasStart(boolean hasStart) {
        this.hasStart = hasStart;
    }

    public boolean isHasGroup() {
        return hasGroup;
    }

    public void setHasGroup(boolean hasGroup) {
        this.hasGroup = hasGroup;
    }

    public boolean isReadOnly() {
        return readOnly;
    }

    public void setReadOnly(boolean readOnly) {
        this.readOnly = readOnly;
    }

    public boolean isHasOnlyNode() {
        return hasOnlyNode;
    }

    public void setHasOnlyNode(boolean hasOnlyNode) {
        this.hasOnlyNode = hasOnlyNode;
    }

    public String getIpPort() {
        return ipPort;
    }

    public void setIpPort(String ipPort) {
        this.ipPort = ipPort;
    }
}
